//
//  WPMineThirdView.m
//  wobingwoyi
//
//  Created by WGP on 16/7/27.
//  Copyright © 2016年 WGP. All rights reserved.
//

#import "WPMineThirdView.h"

@implementation WPMineThirdView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        [self setupUI];
    }
    return self;
}

-(void)setupUI
{
    self.backgroundColor = RGB_SAME(245);
    
    WPMineThirdBtn *informationsBtn = [WPMineThirdBtn mineBtnWith:@"wodexiaoxi" title:@"我的消息" mineBtnType:WPMineBtnTypesFirst];
    WPMineThirdBtn *inviteFriendsBtn = [WPMineThirdBtn mineBtnWith:@"yaoqinghaoyou" title:@"邀请好友" mineBtnType:WPMineBtnTypesSecond];
    WPMineThirdBtn *firstBtn = [WPMineThirdBtn mineBtnWith:@"iconfont-guanyuwomen" title:@"关于我们" mineBtnType:WPMineBtnTypesThird];
     WPMineThirdBtn *secondBtn = [WPMineThirdBtn mineBtnWith:@"yijianfankui" title:@"意见反馈" mineBtnType:WPMineBtnTypesFourth];
     WPMineThirdBtn *thirdBtn = [WPMineThirdBtn mineBtnWith:@"dianhua" title:@"联系客服" mineBtnType:WPMineBtnTypesFourth];
    
    [self addSubview:informationsBtn];
    [self addSubview:inviteFriendsBtn];
    [self addSubview:firstBtn];
    [self addSubview:secondBtn];
    [self addSubview:thirdBtn];
    
    UIView *firstLine = [self lineView];
    UIView *secondLine = [self lineView];
    UIView *thirdLine = [self lineView];
    UIView *fourthLine = [self lineView];
    UIView *fifthLine = [self lineView];
    UIView *sixthLine = [self lineView];
    
    [informationsBtn addTarget:self  action:@selector(mineThirdBtnDidClick:) forControlEvents:UIControlEventTouchDown];
    [inviteFriendsBtn addTarget:self  action:@selector(mineThirdBtnDidClick:) forControlEvents:UIControlEventTouchDown];
    [firstBtn addTarget:self  action:@selector(mineThirdBtnDidClick:) forControlEvents:UIControlEventTouchDown];
     [secondBtn addTarget:self  action:@selector(mineThirdBtnDidClick:) forControlEvents:UIControlEventTouchDown];
     [thirdBtn addTarget:self  action:@selector(mineThirdBtnDidClick:) forControlEvents:UIControlEventTouchDown];
    
    [informationsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(SCREEN_WIDTH);
        make.height.mas_equalTo(44*SCALE);
        make.left.top.equalTo(self);
    }];
    
    [inviteFriendsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(informationsBtn);
        make.top.equalTo(informationsBtn.mas_bottom);
        make.height.equalTo(informationsBtn);
    }];
    
    [firstBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(inviteFriendsBtn);
        make.top.equalTo(inviteFriendsBtn.mas_bottom);
        make.height.equalTo(inviteFriendsBtn);
    }];
    
    [secondBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(firstBtn);
        make.top.equalTo(firstBtn.mas_bottom);
        make.height.equalTo(firstBtn);
    }];
    
    [thirdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(secondBtn);
        make.top.equalTo(secondBtn.mas_bottom);
        make.height.equalTo(secondBtn);
    }];
    
    [firstLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.right.top.equalTo(self);
    }];
    
    [secondLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self).offset(15);
        make.right.bottom.equalTo(informationsBtn);
    }];
    
    [thirdLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self).offset(15);
        make.right.bottom.equalTo(inviteFriendsBtn);
    }];
    
    [fourthLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.equalTo(self).offset(15);
        make.right.bottom.equalTo(firstBtn);
    }];
    
    [fifthLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.right.bottom.equalTo(secondBtn);
    }];
    
    [sixthLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.left.right.bottom.equalTo(thirdBtn);
    }];
}

-(void)mineThirdBtnDidClick:(WPMineThirdBtn *)btn
{
    if ([self.delegate respondsToSelector:@selector(WPMineThirdViewDelegate:mineClickType:)]) {
        
        [self.delegate WPMineThirdViewDelegate:self  mineClickType:btn.btnType];
    }
}

-(UIView *)lineView
{
    UIView *lineView = [UIView new];
    lineView.backgroundColor = RGB_SAME(220);
    [self addSubview:lineView];
    return lineView;
}


@end
